using System.Collections;
using System.Collections.Generic;
using QFramework;
using UnityEngine;

public class SkillData : AbstractModel
{
    [SerializeField]
    private TextAsset skillData;

    public List<Skill> Skills { get; private set; } = new List<Skill>();

    protected override void OnInit()
    {
        LoadSkillData();
    }

    public void LoadSkillData()
    {
        this.skillData = Resources.Load<TextAsset>("Data/SkillData");
        string[] dataRow = this.skillData.text.Split('\n');
        foreach (string row in dataRow)
        {
            var rowArray = row.Split(',');
            if (rowArray[0] == "技能ID")
                continue;
            if (rowArray.Length != 6)
                continue;

            int id = int.Parse(rowArray[0]);
            string name = rowArray[1];
            string description = rowArray[2];
            int value = 0;
            if(int.TryParse(rowArray[5], out int tempValue))
            {
                value = tempValue;
            }

            var skill = new Skill();
            skill.Id = id;
            skill.Name = name;
            skill.Description = description;
            skill.Value = value;
            Skills.Add(skill);
        }
    }
}
